package edu.uwlax.cs.oayonlinestore.client.utils;

public class ErrorText extends Text {

	public final static String STYLE_ERROR_TEXT = "ErrorText";

	boolean empty = true;

	public ErrorText() {
		super();
		setStyleName(STYLE_ERROR_TEXT);
	}

	public ErrorText(String arg0) {
		super(arg0);
		setStyleName(STYLE_ERROR_TEXT);
	}

	public ErrorText(String arg0, boolean arg1) {
		super(arg0, arg1);
		setStyleName(STYLE_ERROR_TEXT);
	}

	public void addError(String text) {
		empty = false;
		setText(getText() + "\n" + text);
	}

	public void addError(Throwable t) {
		addError(ExceptionTool.extractUserMessage(t));
	}

	public void clear() {
		empty = true;
		setText("");
	}

	public boolean isEmpty() {
		return empty;
	}

}
